
package com.ffcs.crmd.tsp.admin.facade.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ctg.itrdc.platform.common.entity.PageInfo;
import com.ctg.itrdc.platform.common.utils.bean.BeanUtils;
import com.ffcs.crmd.platform.core.ddd.facade.impl.AbstractCrmDomFacade;
import com.ffcs.crmd.tsp.admin.api.dto.ClusterInstanceDTO;
import com.ffcs.crmd.tsp.admin.api.facade.IClusterInstanceFacade;
import com.ffcs.crmd.tsp.admin.entity.ClusterInstance;
import com.ffcs.crmd.tsp.admin.service.IClusterInstanceService;
import com.ffcs.crmd.tsp.common.exception.TspException;

@Service("clusterInstanceFacade")
public class ClusterInstanceFacadeImpl extends AbstractCrmDomFacade implements IClusterInstanceFacade {
   	
   	@Autowired
	private IClusterInstanceService clusterInstanceService;
	   
    
    private PageInfo<ClusterInstanceDTO> copyPageInfo(PageInfo<ClusterInstance> pageInfo) throws Exception{
        PageInfo<ClusterInstanceDTO> pageInfoDto = new PageInfo<ClusterInstanceDTO>();
        BeanUtils.applyIf(pageInfoDto, pageInfo, false);
        pageInfoDto.setList(BeanUtils.copyList(pageInfo.getList(), ClusterInstanceDTO.class));
        return pageInfoDto;
    }


    /**
     * 功能说明:
     * 
     * @param clusterName
     * @return
     * @throws TspException
     */
    @Override
    public List<ClusterInstanceDTO> query(String clusterName) throws Exception {
        List<ClusterInstance> clusterInstanceList = clusterInstanceService.query(clusterName);
        return BeanUtils.copyList(clusterInstanceList, ClusterInstanceDTO.class);
    }


    /**
     * 功能说明:
     * 
     * @param clusterName
     * @param pageNumber
     * @param pageSize
     * @return
     * @throws TspException
     */
    @Override
    public PageInfo<ClusterInstanceDTO> queryPage(String clusterName, int pageNumber, int pageSize) throws Exception {
        PageInfo<ClusterInstance> pageInfo = clusterInstanceService.queryPage(clusterName, pageNumber, pageSize);
        return copyPageInfo(pageInfo);
    }
}
